<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      span {
        display: inline-block;
        width: 100px;
        height: 30px;
        line-height: 30px;
        text-align: center;
        border: 1px solid #000;
        margin-right: 10px;
        cursor: pointer;
      }

      span:hover {
        background-color: #ccc;
      }

      .box {
        width: 600px;
        height: 400px;
        position: relative;
      }

      .box div {
        width: 100%;
        height: 100%;
        display: none;
        position: absolute;
        top: 0;
      }

      .s1 {
        background-color: #ccc;
      }

      .box div:nth-of-type(1) {
        display: block;
        background-color: bisque;
      }

      .box div:nth-of-type(2) {
        background-color: #6ec9ed;
      }

      .s1:hover ~ .box div:nth-of-type(1) {
        display: block;
      }
      /* has 拥有
            + 紧跟 
            :is 有
        */
      .s1:has(+ .s2:is(:hover)) {
        background-color: #fff;
      }

      .s2:hover ~ .box div:nth-of-type(2) {
        display: block;
      }
    </style>
  </head>
  <body>
    <span class="s1">tab1</span>
    <span class="s2">tab2</span>
    <div class="box">
      <div>tab1</div>
      <div>tab2</div>
    </div>
  </body>
</html>
